From b4ac07ed8e9ddd782c1c6269a7918238de8ea866 Mon Sep 17 00:00:00 2001 From: "tsteven4@gmail.com" Date: Sat, 15 Feb 2014 21:19:33 +0000 Subject: [PATCH] Refactor route_head to move functonality from old functions to ctor/dtors. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4743 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/defs.h | 16 ++++------------ gpsbabel/route.cc | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 2a6fe5817..8e9182709 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -561,18 +561,6 @@ public: class route_head { public: - route_head() : -#if NEW_STRINGS -#else - rte_name(NULL), - rte_desc(NULL), -#endif - rte_num(0), - rte_waypt_ct(0), - fs(NULL), - cet_converted(0), - line_width(-1), - session(NULL) {} queue Q; /* Link onto parent list. */ queue waypoint_list; /* List of child waypoints */ String rte_name; @@ -585,6 +573,10 @@ public: gb_color line_color; /* Optional line color for rendering */ int line_width; /* in pixels (sigh). < 0 is unknown. */ session_t* session; /* pointer to a session struct */ + +public: + route_head(); + ~route_head(); }; /* diff --git a/gpsbabel/route.cc b/gpsbabel/route.cc index ab7f75401..d58ea11e1 100644 --- a/gpsbabel/route.cc +++ b/gpsbabel/route.cc @@ -68,24 +68,16 @@ route_head* route_head_alloc(void) { route_head* rte_head = new route_head; - QUEUE_INIT(&rte_head->Q); - QUEUE_INIT(&rte_head->waypoint_list); - rte_head->session = curr_session(); return rte_head; } static void any_route_free(route_head* rte) { - waypt_flush(&rte->waypoint_list); - if (rte->fs) { - fs_chain_destroy(rte->fs); - } delete rte; rte = NULL; } - static void any_route_add_head(route_head* rte, queue* head) { @@ -698,3 +690,31 @@ void track_recompute(const route_head* trk, computed_trkdata** trkdatap) xfree(tdata); } } + +route_head::route_head() : + // Q(), + // waypoint_list(), +#if !NEW_STRINGS + rte_name(NULL), + rte_desc(NULL), +#endif + // rte_url(), + rte_num(0), + rte_waypt_ct(0), + fs(NULL), + cet_converted(0), + // line_color(), + line_width(-1), + session(curr_session()) +{ + QUEUE_INIT(&Q); + QUEUE_INIT(&waypoint_list); +}; + +route_head::~route_head() +{ + waypt_flush(&waypoint_list); + if (fs) { + fs_chain_destroy(fs); + } +} -- 2.30.2